﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Truextend.CoffeShop.Model;

namespace Truextend.CoffeShop.DataAccess
{
    public class ProductsDataAccess
    {
        static CoffeShopEntities db = new CoffeShopEntities();

        public static List<Model.Product> GetAllInternalProducts()
        {
            List<Product> listInternalProducts = new List<Product>();
            
            try {

                listInternalProducts = (from p in db.Product where p.Restaurant.RestaurantId == 1 select p).ToList();

            }catch(Exception){}

            return listInternalProducts;
        }

        public static List<Product> GetAllProductsForRestaurant(int restaurantId) {

            List<Product> listProducts = new List<Product>();

            try {

                listProducts = (from p in db.Product where p.Restaurant.RestaurantId == restaurantId select p).ToList();
            
            }catch(Exception){}

            return listProducts;
        
        }

        public static Product GetProductById(int productId) {

            Product product = new Product();

            try {
                product = (from p in db.Product where p.ProductId == productId select p).First();
            }
            catch (Exception) { }

            return product;
        }
    }
}
